import { Button } from "antd";
import { useModel } from "@/.umi/plugin-model/useModel";
import ProductList from '@/components/ProductList'
// import useProductList from '@/models/useProductList'

export default () => {
  const {params,refresh,tableProps} = useModel('useProductList')
  // const {params,refresh,tableProps} = useProductList()
  const { sorter = {}, filters = {} } = params[0] || ({} as any);
  const columns = [
    {
      title: "name",
      dataIndex: "name"
    },
    {
      title: "email",
      dataIndex: "email"
    },
    {
      title: "id",
      dataIndex: "id",
      sorter: true,
      sortOrder: sorter.field === "id" ? sorter.order : false
    },
    {
      title: "gender",
      dataIndex: "gender",
      filters: [
        { text: "male", value: "male" },
        { text: "female", value: "female" }
      ],
      filteredValue: filters.gender
    }
  ];
  return (
    <div>
      <Button onClick={refresh} style={{ marginBottom: 16 }}>
        刷新
      </Button>
      <ProductList columns={columns} rowKey="id" tableProps={tableProps} />
    </div>
  );
};
